package com.yt.sys.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.sys.common.config.YmlConfig;
import com.yt.sys.mapper.SysPermissionMapper;
import com.yt.sys.models.bo.SysPermissionSaveBO;
import com.yt.sys.models.dto.SysPermissionDTO;
import com.yt.sys.models.service.ISysPermissionService;
import com.yt.sys.models.vo.SysPermissionVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统权限信息控制器
 *
 * @author zhou
 * @Date 2025-09-03 15:12:37
 */
@DubboService
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermissionDTO> implements ISysPermissionService {

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(SysPermissionSaveBO saveBO) {
        SysPermissionDTO dto = new SysPermissionDTO();
        BeanUtils.copyProperties(saveBO, dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }

    @Override
    public List<SysPermissionVO> queryPermission() {
        List<SysPermissionVO> sysPermissionVOS = baseMapper.query();
        return sysPermissionVOS;
    }
}
